﻿<div ms-controller="CCXJBRANCH">
    <!-- 按条件选择 -->
    <div class="tab-filter-type">
        <div class="oh">
            <!-- 搜索 -->
            <div class="oh pl20 pr20">
                

                <input type="search" class="form-control szhl_form_date_year pull-left" ms-duplex="curYear" placeholder="请选择年份" style="width:100px">
                   
                <select class="form-control pull-left" ms-duplex="curMonth" style="width:100px;margin-left:10px;" ms-change="GetLIST()">
                    <option value="0">全部月份</option>
                    <option value="01">1月</option>
                    <option value="02">2月</option>
                    <option value="03">3月</option>
                    <option value="04">4月</option>
                    <option value="05">5月</option>
                    <option value="06">6月</option>
                    <option value="07">7月</option>
                    <option value="08">8月</option>
                    <option value="09">9月</option>
                    <option value="10">10月</option>
                    <option value="11">11月</option>
                    <option value="12">12月</option>
                </select>
                    <div class="input-group ml15 pull-left" style="width:295px;">
                        <input type="search" class="form-control" ms-duplex="search.searchcontent" placeholder="请输入姓名查询">
                        <span class="input-group-addon" ms-click="GetLIST()">搜索</span>
                    </div>             
            </div>
        </div>
        <!-- 展开更多选项 -->
        <div class="add-tab ft14 tc mt20" style="display:none;">
            <span>更多筛选<i class="caret"></i></span>
        </div>
        <!-- 表格 -->
        <div class="default-tab ft14 pt20">
            <table class="table table-striped table-responsive table-hover">
                <thead>
                    <tr>
                        <th class="tc">
                        </th>
                        <th ms-repeat-im="ShowColumns" ms-visible="im.IsSel">{{im.ColText}}</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    <tr ms-repeat-el="ListData">
                        <td class=" tc">
                        
                        </td>
                        <td ms-repeat-im="ShowColumns" ms-visible="im.IsSel">{{ComFunJS.FnFormat(el[im.ColName],im)|html}}</td>
                        <td>
                            <a ms-click="ViewForm(el.CRUser,el.ccMonth,el.LeiBie)" class="cz-btn ft18 bj-color tip" data-toggle="tooltip" title="" data-original-title="查看">
                                <i class="iconfont icon-look"></i>
                            </a>
                        </td>
                    </tr>

                </tbody>
                <tfoot>
                    <tr ms-if="isnull"><td class="tc"></td><td>暂无数据</td></tr>
                </tfoot>
            </table>
            <div class="ui-datatable-page ft14 pl20">

                <div id="pageDiv" ms-visible="model.page.total>model.pageNum[0].num" class="pull-right"></div>
                <div class="pull-right" ms-visible="ListData.size()!=0">
                    <span>共{{model.page.total}}条记录</span>
                    <span ms-visible="model.page.total>model.pageNum[0].num">
                        选择每页条数
                        <select style="height: 25px; width: 50px;" ms-change="selNum(this.value)" ms-duplex="model.page.pagecount">
                            <option ms-repeat-pg="pageNum" ms-attr-value="pg.num" ms-attr-selected="pg.num==model.page.pagecount?'selected':''">{{pg.num}}</option>
                        </select>
                    </span>
                </div>

            </div>
        </div>
    </div>

    <script>

        var tempindex = avalon.define({
            $id: "CCXJBRANCH",
            curYear: "",
            curMonth: "0",
            InitWigetData: function () {
                ComFunJS.initForm();
                //显示的列名
                model.ShowColumns.clear();
                model.ShowColumns.pushArray([
                    { "ColName": "ShenQingRen", "ColText": "姓名", "IsSel": true, "format": "text" },
                    { "ColName": "BranchName", "ColText": "部门", "IsSel": true, "format": "text" },
                    { "ColName": "ccMonth", "ColText": "月份", "IsSel": true, "format": "text" },
                    { "ColName": "TypeName", "ColText": "假别", "IsSel": true, "format": "text" },
                    { "ColName": "daycount", "ColText": "天数", "IsSel": true, "format": "text" }
                ]);

                var now = new Date();
                var month = now.getMonth() + 1;
                var clock = "";
                if (month < 10)
                    clock += "0";
                clock += month;
                tempindex.curMonth = clock;

                tempindex.GetLIST();
            },
            selNum: function (item) {    //选择显示的条数
                model.page.pagecount = item;
                tempindex.GetLIST();
            },
            GetLIST: function () {
                model.ListData.clear();

                $.getJSON('/API/VIEWAPI.ashx?Action=CCXJ_GETCCXJTJ', { pagecount: model.page.pagecount, P1: tempindex.curYear, P2: tempindex.curMonth, search: model.search.searchcontent }, function (resultData) {
                    if (resultData.ErrorMsg == "") {
                        model.ListData = resultData.Result;
                        if (model.ListData.size() == 0) { model.isnull = true; } else { model.isnull = false; }
                        model.page.total = resultData.Result1;
                        laypage({
                            cont: 'pageDiv', //容器。值支持id名、原生dom对象，jquery对象。
                            pages: Math.ceil(parseInt(resultData.Result1) * 1.0 / model.page.pagecount), //
                            curr: 1, //初始化当前页
                            skin: 'molv',
                            jump: function (e) { //触发分页后的回调
                                if (e.curr != model.page.pageindex) {
                                    $.getJSON('/API/VIEWAPI.ashx?Action=CCXJ_GETCCXJTJ', { pagecount: model.page.pagecount, p: e.curr, P1: tempindex.curYear, P2: tempindex.curMonth, search: model.search.searchcontent }, function (resultData) {
                                        if (resultData.ErrorMsg == "") {
                                            model.ListData = resultData.Result;
                                        }
                                    })
                                    model.page.pageindex = e.curr;
                                }
                            }
                        });

                    }
                })
            },ViewForm: function (username,month,type) { 
                ComFunJS.winviewform("/ViewV5/AppPage/CCXJ/CCXJUserLIST.html?username=" + username + "&month=" + month + "&type=" + type, "出差请假详情", "1000");
            }
        })
    </script>
